﻿@using TomNet.IMSC.Model.DbModels.NewHouse;
@{
    var entity = ViewBag.entity as Buildings;
    Layout = null;
}

<!DOCTYPE html>


<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/Css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="~/Content/Css/animate.css" rel="stylesheet">
    <link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">
    <title>EditPropertyDetailsedit</title>
    <link href="/Content/Css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="~/Content/common.css" rel="stylesheet"> 
    <link href="~/Content/Css/plugins/multiselect/bootstrap-multiselect.css" rel="stylesheet" />
    <style> 
        /*.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-12,
         .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-12{
             border-style:solid; border-width:1px; border-color:#000;
        }*/ 
        
        .ibox,#DecorationCondition {
            margin-bottom: 0px;
        }
            

        .multiselect-container input[type="checkbox"],#DecorationCondition {
            margin-top: 7px;
        }
        .pull-left,#DecorationCondition {
            padding-left:0px;
        }
    </style>
</head>
<body>
    <div class="wrapper wrapper-content animated fadeInRight">
        <form class="form-horizontal m-t" id="mainForm">

            <input type="hidden" id="Id" name="Id" value="@ViewBag.entity.Id" /> 

            <div class="row">
                <div class="col-sm-6">   
                    <div class="form-group">
                        <label class="col-xs-3 control-label">开盘时间：</label>
                        <div class="col-xs-9">
                            <input id="OpeningTime" name="OpeningTime" value="@entity.OpeningTime" class="form-control" placeholder="开盘时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请选择开盘时间</span> 
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-3 control-label">交房时间：</label>
                        <div class="col-xs-9">
                            <input id="LaunchTime" name="LaunchTime" value="@entity.LaunchTime" class="form-control" placeholder="交房时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请选择交房时间</span>
                        </div>
                    </div> 
                    <div class="form-group">
                        <label class="col-xs-3 control-label">开发商：</label>
                        <div class="col-xs-9">
                            <input id="Developer" name="Developer" value="@entity.Developer" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入开发商</span>
                        </div>
                    </div> 
                    <div class="form-group">
                        <label class="col-xs-3 control-label">开发商品牌：</label>
                        <div class="col-xs-9">
                            <input id="DeveloperBrand" name="DeveloperBrand" value="@entity.DeveloperBrand" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入开发商品牌</span>
                        </div>
                    </div> 
                    <div class="form-group">
                        <label class="col-xs-3 control-label">物业公司：</label>
                        <div class="col-xs-9">
                            <input id="PropertyManagementCompany" name="PropertyManagementCompany" value="@entity.PropertyManagementCompany" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入物业公司</span>
                        </div>
                    </div> 
                    <div class="form-group">
                        <label class="col-xs-3 control-label">建筑面积：</label>
                        <div class="col-xs-9">
                            <input id="CoveredArea" name="CoveredArea" value="@entity.CoveredArea" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入建筑面积</span>
                        </div>
                    </div> 
                    <div class="form-group">
                        <label class="col-xs-3 control-label">总户数：</label>
                        <div class="col-xs-9">
                            <input id="TotalHouseholds" name="TotalHouseholds" value="@entity.TotalHouseholds" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入总户数</span>
                        </div>
                    </div> 
                    <div class="form-group">
                        <label class="col-xs-3 control-label">容积率：</label>
                        <div class="col-xs-9">
                            <input id="PlotRatio" name="PlotRatio" value="@entity.PlotRatio" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入容积率</span>
                        </div>
                    </div> 
                   
                </div>


                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-3 control-label">绿化率：</label>
                        <div class="col-xs-9">
                            <input id="GreeningRatio" name="GreeningRatio" value="@entity.GreeningRatio" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入绿化率</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-3 control-label">车位数：</label>
                        <div class="col-xs-9">
                            <input id="CarNumber" name="CarNumber" value="@entity.CarNumber" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入车位数</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-3 control-label">车位比：</label>
                        <div class="col-xs-9">
                            <input id="ParkingRatio" name="ParkingRatio" value="@entity.ParkingRatio" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入车位比</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-3 control-label">均价：</label>
                        <div class="col-xs-9">
                            <input id="AveragePrice" name="AveragePrice" value="@entity.AveragePrice" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入均价</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-3 control-label">物业费：</label>
                        <div class="col-xs-9">
                            <input id="PropertyManagementFee" name="PropertyManagementFee" value="@entity.PropertyManagementFee" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入物业费</span>
                        </div>
                    </div>
                    <div class="form-group"> 
                        <label class="col-xs-3 control-label">建筑类型：</label>
                        <div class="col-xs-9">
                            <select class="form-control input-sm" name="BuildingClass" id="BuildingClass" multiple="multiple"></select>
                        </div>
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请选择建筑类型</span>
                    </div> 
                    <div class="form-group">
                        <label class="col-xs-3 control-label">装修状况：</label>
                        <div class="col-xs-9">
                            <select class="form-control input-sm" name="DecorationCondition" id="DecorationCondition" multiple="multiple"></select>
                        </div>
                        <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请选择装修状况</span>
                    </div> 
                    <div class="form-group">
                        <label class="col-xs-3 control-label">产权年限：</label>
                        <div class="col-xs-9">
                            <input id="PropertyRight" name="PropertyRight" value="@entity.PropertyRight" type="text" class="form-control">
                            <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>请输入产权年限</span>
                        </div>
                    </div> 
                </div> 
            </div> 
            <div class="row">
                <div class="col-sm-12">
                    <button id="submit" class="btn btn-primary pull-right" type="submit">
                        <i class="fa fa-check"></i>&nbsp;提&nbsp;交
                    </button>
                </div>
            </div>
        </form>
    </div>


    <!-- 全局js -->
    <script type="text/javascript" src="~/Scripts/jquery.min.js?v=2.1.4"></script>
    <script type="text/javascript" src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>
     


    <!-- jQuery Validation plugin javascript-->
    <script type="text/javascript" src="~/Scripts/plugins/validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/validate/messages_zh.min.js"></script>
    <script type="text/javascript" src="~/Scripts/Extensions/ExtValidator.js"></script>

    <!-- layer javascript -->
    <script type="text/javascript" src="~/Scripts/plugins/layer/layer.min.js"></script>
    <script src="/Scripts/plugins/iCheck/icheck.min.js"></script>
    <!-- layerDate plugin javascript -->
    <script type="text/javascript" src="~/Scripts/plugins/layer/laydate/laydate.js"></script>
    <script src="~/Scripts/plugins/multiselect/bootstrap-multiselect.js"></script>

    <script type="text/javascript">
        $(function () {

            //建筑类型多选框
            GetBuidingsClass();
            GetDecorationCondition();

            var icon = "<i class='fa fa-times-circle'></i> ";
            var validator = $("#mainForm").validate({
                rules: {
                    Name: { required: true, },
                    District: { required: true, },
                    SellingPrice: { number: true, },
                    LeasePrice: { number: true, },
                },
                messages: {
                    Name: { required: icon + "请输入楼盘名称", },
                    District: { required: icon + "请选择地区", },
                    SellingPrice: { number: icon + "请输入合法数字", },
                    LeasePrice: { number: icon + "请输入合法数字", },
                },
                submitHandler: function (form) { 
                    $.ajax({
                        url: "/NewHouse/Buildings/EditPropertyDetailseditAsync",
                        type: "post",
                        dataType: "json",
                        data: $('#mainForm').serialize(),
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.type;
                            if (type == 1) {
                                layer.msg(data.content, { icon: 6, time: 2000 },
                                    function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                    });

                            } else {
                                layer.msg(data.content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }
            });
        });

        //建筑类型多选框
        function GetBuidingsClass() {
            console.log();
            $.getJSON(
                "/NewHouse/Buildings/GetBuildingClassEdit",
                function (data) {
                    console.log(data);
                    $("#BuildingClass").find("option").remove();
                    $("#BuildingClass").multiselect("destroy").multiselect({
                        buttonClass: 'btn btn-link',//显示按钮style
                        buttonWidth: '340px',//按钮宽度
                        inheritClass: true,//继承原来select的button的class
                        selectAllNumber: false,//true显示allselect（6）,false显示allselec
                    });
                    $.each(data, function (i, item) {
                        if (item["number"] > 0) {
                            $("<option></option>").val(item["name"]).text(item["name"]).attr("selected", true).appendTo($("#BuildingClass"));


                            $("#BuildingClass").multiselect("destroy").multiselect({
                                buttonClass: 'btn btn-link',//显示按钮style
                                buttonWidth: '340px',//按钮宽度
                                inheritClass: true,//继承原来select的button的class
                                selectAllNumber: false,//true显示allselect（6）,false显示allselec
                            });
                        }
                        else {
                            $("<option></option>").val(item["name"]).text(item["name"]).appendTo($("#BuildingClass"));


                            $("#BuildingClass").multiselect("destroy").multiselect({
                                buttonClass: 'btn btn-link',//显示按钮style
                                buttonWidth: '340px',//按钮宽度
                                inheritClass: true,//继承原来select的button的class
                                selectAllNumber: false,//true显示allselect（6）,false显示allselec
                            });
                        }


                    });
                });
        }

        //装修状况多选框
        function GetDecorationCondition() {
            console.log();
            $.getJSON(
                "/NewHouse/Buildings/GetDecorationConditionEdit",
                function (data) {
                    console.log(data);
                    $("#DecorationCondition").find("option").remove();
                    $("#DecorationCondition").multiselect("destroy").multiselect({
                        buttonClass: 'btn btn-link',//显示按钮style
                        buttonWidth: '340px',//按钮宽度
                        inheritClass: true,//继承原来select的button的class
                        selectAllNumber: false,//true显示allselect（6）,false显示allselec
                    });
                    $.each(data, function (i, item) {
                        if (item["number"] > 0) {
                            $("<option></option>").val(item["name"]).text(item["name"]).attr("selected", true).appendTo($("#DecorationCondition"));


                            $("#DecorationCondition").multiselect("destroy").multiselect({
                                buttonClass: 'btn btn-link',//显示按钮style
                                buttonWidth: '340px',//按钮宽度
                                inheritClass: true,//继承原来select的button的class
                                selectAllNumber: false,//true显示allselect（6）,false显示allselec
                            });
                        }
                        else {
                            $("<option></option>").val(item["name"]).text(item["name"]).appendTo($("#DecorationCondition"));


                            $("#DecorationCondition").multiselect("destroy").multiselect({
                                buttonClass: 'btn btn-link',//显示按钮style
                                buttonWidth: '340px',//按钮宽度
                                inheritClass: true,//继承原来select的button的class
                                selectAllNumber: false,//true显示allselect（6）,false显示allselec
                            });
                        }


                    });
                });
        }
        //日期范围限制
        var start = {
            elem: '#start',
            format: 'YYYY/MM/DD HH:mm:ss',
            min: laydate.now(), //设定最小日期为当前日期
            max: '2099-06-16 23:59:59', //最大日期
            istime: true,
            istoday: false,
            choose: function (datas) {
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };
        var end = {
            elem: '#end',
            format: 'YYYY/MM/DD HH:mm:ss',
            min: laydate.now(),
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
        laydate(start);
        laydate(end);

    </script>
</body>
</html>
